import { fromJS } from 'immutable'
import * as constant from './constant'
const defaultState = fromJS({
  articleList: [],
  writerList: [],
  articlePage: 1
})
export default ((state = defaultState, action) => {
  switch (action.type){
    case constant.CHANGE_BOARD_DATA:
        return state.merge({
            articleList: fromJS(action.articleList),
            writerList: fromJS(action.writerList)
        })
        case constant.GET_MORE_ARTICLE:
        return state.merge({
            'articleList': state.get('articleList').concat(action.list),
            'articlePage': action.nextPage
        })
    
    default:
      return state;
  }
})